<template>
  <div>
    <ele-pro-table
      ref="table"
      size="mini"
      :columns="columns"
      :datasource="datasource"
      :selection.sync="selection"
      :need-page="true"
      :hideOnSinglePage="false"
    >
      <template v-slot:days="{ row }">
        <div>{{row.packageDays}}天</div>
      </template>

      <!--操作-->
      <template v-slot:action="{ row }">
        <el-link
          type="primary"
          :underline="false"
          @click.stop="edit(row)"
        >
          设置价格
        </el-link>
      </template>
    </ele-pro-table>
    <pop-edit
      ref="pop"
      :visible.sync="visible"
      @done="reload"></pop-edit>
  </div>
</template>

<script>
  import {queryAgentCamera, saveAgentCamera} from "@/api/lncomingManagement/carmeraAgent"
  import PopEdit from "@/views/lncomingManagement/carmeraAgent/card/components/pop-edit";

  export default {
    name: "table-list",
    components: {PopEdit},
    props: {
      form:Object
    },
    data() {
      return {
        visible:false,
        // 表格选中数据
        selection: [],
        columns: [
          {
            columnKey: 'selection',
            type: 'selection',
            width: 45,
            align: 'center'
          },
          {
            columnKey: 'index',
            type: 'index',
            width: 140,
            align: 'center',
            fixed: 'left',
            label: '排序值'
          },
          {
            prop: 'packageName',
            label: '套餐名称',
            align: 'center',
            showOverflowTooltip: true,
          },
          {
            prop: 'packageDays',
            label: '套餐天数',
            align: 'center',
            showOverflowTooltip: true,
            slot: 'days',
          },
          {
            prop: 'packagePrice',
            label: '套餐价格（元）',
            align: 'center',
            showOverflowTooltip: true,
          },
          {
            prop: 'createTime',
            label: '创建时间',
            align: 'center',
            showOverflowTooltip: true,
          },
          /*{
            label: '操作',
            align: 'center',
            showOverflowTooltip: true,
            slot: 'password ',
            fixed: 'right',

          },*/
          {
            label: '操作',
            columnKey: 'action',
            align: 'center',
            resizable: false,
            slot: 'action',
            hideInSetting: true,
            showOverflowTooltip: true,
            fixed: 'right'
          }
        ]
      };
    },
    methods: {
      // 编辑套餐
      edit(row){
        console.log("row",row)
        this.visible=true
        this.$nextTick(()=>{
          this.$refs['pop'].show(row) //单列套餐数据
        })
      },
      /* 刷新————表格数据源 */
      datasource({ page, limit, where, order }) {
        return queryAgentCamera({ ...where, ...order, page, limit, ...this.form });
      },
      /* 刷新表格 */
      reload(where) {
        this.$refs.table.reload({ page: 1, where: where });
      },
    },
    watch: {

    }
  };
</script>

<style scoped lang="less">

</style>
